<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Plack::Middleware::Rewrite - mod_rewrite for Plack - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Plack-Middleware-Rewrite - MetaCPAN" href="https://metacpan.org/dist/Plack-Middleware-Rewrite/releases.rss" />
        <link rel="canonical" href="./Plack::Middleware::Rewrite.html" />
        <meta name="description" content="mod_rewrite for Plack" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Plack::Middleware::Rewrite" />
<meta name="twitter:title"       content="Plack::Middleware::Rewrite" />
<meta name="twitter:description" content="mod_rewrite for Plack" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Plack::Middleware::Rewrite.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Plack-Middleware-Rewrite was released.">
      <span class="relatize">04 Sep 2022 14:03:04 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Plack-Middleware-Rewrite">Plack-Middleware-Rewrite</a>
  </li>
  <li>
    Module version: 2.102
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Plack-Middleware-Rewrite/source/lib/Plack/Middleware/Rewrite.pm">Source</a>
    (<a href="https://metacpan.org/dist/Plack-Middleware-Rewrite/source/lib/Plack/Middleware/Rewrite.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Plack-Middleware-Rewrite/source/lib/Plack/Middleware">Browse</a>
    (<a href="https://metacpan.org/dist/Plack-Middleware-Rewrite/source/lib/Plack/Middleware?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Plack-Middleware-Rewrite/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Plack-Middleware-Rewrite/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/ap/Plack-Middleware-Rewrite">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Plack-Middleware-Rewrite">Issues</a>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Plack-Middleware-Rewrite+2.102" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-Rewrite.html?oncpan=1&amp;distmat=1&amp;version=2.102&amp;grade=2" style="color: #090">297</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-Rewrite.html?oncpan=1&amp;distmat=1&amp;version=2.102&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-Rewrite.html?oncpan=1&amp;distmat=1&amp;version=2.102&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/ARISTOTLE/Plack-Middleware-Rewrite-2.102">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Plack-Middleware-Rewrite who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Plack-Middleware-Rewrite-2.102/index.html">92.00% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.6.0
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Plack-Middleware-Rewrite/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/A/AR/ARISTOTLE/Plack-Middleware-Rewrite-2.102.tar.gz">
      Download (<span itemprop="fileSize">15.62KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FARISTOTLE%2FPlack-Middleware-Rewrite-2.102%2Flib%2FPlack%2FMiddleware%2FRewrite.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Plack-Middleware-Rewrite/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Plack-Middleware-Rewrite/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Plack-Middleware-Rewrite">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Plack-Middleware-Rewrite">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Plack/Middleware/Rewrite.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.102"
>2.102
  (ARISTOTLE on 2022-09-04)</option>
<optgroup label="BackPAN">'
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.101"
>2.101
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.100"
>2.100
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.000"
>2.000
  (ARISTOTLE on 2015-05-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.101"
>1.101
  (ARISTOTLE on 2015-03-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.100"
>1.100
  (ARISTOTLE on 2015-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.010"
>1.010
  (ARISTOTLE on 2015-01-09)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.009"
>1.009
  (ARISTOTLE on 2015-01-02)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.008"
>1.008
  (ARISTOTLE on 2014-02-28)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.007"
>1.007
  (ARISTOTLE on 2013-02-12)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.006"
>1.006
  (ARISTOTLE on 2012-12-27)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.005"
>1.005
  (ARISTOTLE on 2012-06-07)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.004"
>1.004
  (ARISTOTLE on 2012-03-29)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.003"
>1.003
  (ARISTOTLE on 2011-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.002"
>1.002
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.001"
>1.001
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.0"
>1.0
  (ARISTOTLE on 2011-02-16)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/ARISTOTLE/Plack-Middleware-Rewrite-2.102/diff/' + encodeURIComponent(this.value) + '/lib/Plack/Middleware/Rewrite.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.102"
>2.102
  (ARISTOTLE on 2022-09-04)</option>
<optgroup label="BackPAN">'
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.101"
>2.101
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.100"
>2.100
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.000"
>2.000
  (ARISTOTLE on 2015-05-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.101"
>1.101
  (ARISTOTLE on 2015-03-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.100"
>1.100
  (ARISTOTLE on 2015-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.010"
>1.010
  (ARISTOTLE on 2015-01-09)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.009"
>1.009
  (ARISTOTLE on 2015-01-02)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.008"
>1.008
  (ARISTOTLE on 2014-02-28)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.007"
>1.007
  (ARISTOTLE on 2013-02-12)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.006"
>1.006
  (ARISTOTLE on 2012-12-27)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.005"
>1.005
  (ARISTOTLE on 2012-06-07)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.004"
>1.004
  (ARISTOTLE on 2012-03-29)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.003"
>1.003
  (ARISTOTLE on 2011-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.002"
>1.002
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.001"
>1.001
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.0"
>1.0
  (ARISTOTLE on 2011-02-16)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="Plack.html" title="Plack" class="ellipsis">Plack</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Middleware" title="Plack::Middleware" class="ellipsis">Plack::Middleware</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Request" title="Plack::Request" class="ellipsis">Plack::Request</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Util" title="Plack::Util" class="ellipsis">Plack::Util</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Util::Accessor" title="Plack::Util::Accessor" class="ellipsis">Plack::Util::Accessor</a></li>
  <li><a href="https://metacpan.org/pod/overload" title="overload" class="ellipsis">overload</a></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Plack::Middleware::Rewrite/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Plack%3A%3AMiddleware%3A%3ARewrite">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Plack-Middleware-Rewrite">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/ARISTOTLE/Plack-Middleware-Rewrite-2.102/view/lib/Plack/Middleware/Rewrite.pm">This version</a>
    </li>
    <li>
      <a href="./Plack::Middleware::Rewrite.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/RRWO"><img src="https://www.gravatar.com/avatar/4a5274bc5d690ee3d619f044778771a7?d=identicon&amp;s=20" title="RRWO" alt="RRWO"></a>
<a class="display-all" href="https://metacpan.org/author/OALDERS"><img src="https://www.gravatar.com/avatar/7a66ba9f5f4af93dd55fcdc0e69c0b55?d=identicon&amp;s=20" title="OALDERS" alt="OALDERS"></a>
<a class="display-all" href="https://metacpan.org/author/NICKL"><img src="https://www.gravatar.com/avatar/46666dab0b20c81e2aa6751470934dca?d=identicon&amp;s=20" title="NICKL" alt="NICKL"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Plack-Middleware-Rewrite/plussers">3 PAUSE users</a>
</div>
</div>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/ARISTOTLE" class="author-name">Αριστοτέλης Παγκαλτζής</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Plack/Middleware/Rewrite.pm&#39;" class="">
<option
  selected
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.102"
>2.102
  (ARISTOTLE on 2022-09-04)</option>
<optgroup label="BackPAN">'
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.101"
>2.101
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.100"
>2.100
  (ARISTOTLE on 2018-02-26)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-2.000"
>2.000
  (ARISTOTLE on 2015-05-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.101"
>1.101
  (ARISTOTLE on 2015-03-14)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.100"
>1.100
  (ARISTOTLE on 2015-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.010"
>1.010
  (ARISTOTLE on 2015-01-09)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.009"
>1.009
  (ARISTOTLE on 2015-01-02)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.008"
>1.008
  (ARISTOTLE on 2014-02-28)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.007"
>1.007
  (ARISTOTLE on 2013-02-12)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.006"
>1.006
  (ARISTOTLE on 2012-12-27)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.005"
>1.005
  (ARISTOTLE on 2012-06-07)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.004"
>1.004
  (ARISTOTLE on 2012-03-29)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.003"
>1.003
  (ARISTOTLE on 2011-03-01)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.002"
>1.002
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.001"
>1.001
  (ARISTOTLE on 2011-02-17)</option>
<option
  
  value="ARISTOTLE/Plack-Middleware-Rewrite-1.0"
>1.0
  (ARISTOTLE on 2011-02-16)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Plack-Middleware-Rewrite">Plack-Middleware-Rewrite-2.102</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage zero &#10;
          No dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="5"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Plack-Middleware-Rewrite-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Plack-Middleware-Rewrite-2.102">
    <input type="hidden" name="author" value="ARISTOTLE">
    <input type="hidden" name="distribution" value="Plack-Middleware-Rewrite">
    <button type="submit" class="favorite highlight"><span>3</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Plack::Middleware::Rewrite.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>3</span> ++</a>
</div>
   / <span>Plack::Middleware::Rewrite</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Plack::Middleware::Rewrite.html#NAME">NAME</a></li>
  <li><a href="./Plack::Middleware::Rewrite.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Plack::Middleware::Rewrite.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./Plack::Middleware::Rewrite.html#CONFIGURATION-OPTIONS">CONFIGURATION OPTIONS</a>
    <ul>
      <li><a href="./Plack::Middleware::Rewrite.html#request">request</a></li>
      <li><a href="./Plack::Middleware::Rewrite.html#response">response</a></li>
    </ul>
  </li>
  <li><a href="./Plack::Middleware::Rewrite.html#LEGACY-INTERFACE">LEGACY INTERFACE</a>
    <ul>
      <li><a href="./Plack::Middleware::Rewrite.html#Porting-from-the-old-to-the-new-interface">Porting from the old to the new interface</a></li>
    </ul>
  </li>
  <li><a href="./Plack::Middleware::Rewrite.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./Plack::Middleware::Rewrite.html#COPYRIGHT-AND-LICENSE">COPYRIGHT AND LICENSE</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Plack::Middleware::Rewrite - mod_rewrite for Plack</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code> # in app.psgi
 use Plack::Builder;
 
 builder {
     enable &#39;Rewrite&#39;, request =&gt; sub {
         s{^/here(?=/|$)}{/there};

         return [303]
             if s{^/foo/?$}{/bar/}
             or s{^/baz/?$}{/quux/};

         return [301, [ Location =&gt; &#39;http://example.org/&#39; ], []]
             if m{^/example/?$};

         return [201] if $_ eq &#39;/favicon.ico&#39;;

         return [503] if -e &#39;/path/to/app/maintenance.lock&#39;;

         return [200, [qw(Content-Type text/plain)], [&#39;You found it!&#39;]]
             if $_ eq &#39;/easter-egg&#39;;
     },
     response =&gt; sub {
         $_-&gt;status( 303 )
             if $_-&gt;status eq 201 and $_-&gt;get( &#39;Location&#39; );

         $_-&gt;set( &#39;Content-Type&#39;, &#39;application/xhtml+xml&#39; )
             if ( $_[0]{&#39;HTTP_ACCEPT&#39;} || &#39;&#39; ) =~ m{application/xhtml\+xml(?!\s*;\s*q=0)};
     };
     $app;
 };</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>This middleware provides a convenient way to modify requests in flight in Plack apps. Rewrite rules are simply written in Perl, which means everything that can be done with mod_rewrite can be done with this middleware much more intuitively (if in syntactically wordier ways). Its primary purpose is rewriting paths, but almost anything is possible very easily.</p>

<h1 id="CONFIGURATION-OPTIONS"><a id="CONFIGURATION"></a>CONFIGURATION OPTIONS</h1>

<h2 id="request"><code>request</code></h2>

<p>Takes a reference to a function that will be called in scalar context for each request. On call, <code>$_</code> will be aliased to <code>PATH_INFO</code>, so that you can easily use regexp matches and subtitutions to examine and modify it. The <a href="PSGI.html">PSGI</a> environment will be passed to the function as its first and only argument.</p>

<p>The function may return three kinds of valid value:</p>

<dl>

<dt id="A-plain-scalar"><a id="A"></a>A plain scalar</dt>
<dd>

<p>Ignored. The value will be thrown away and any path rewriting (or any other modifications of the PSGI environment) will take effect during the current request cycle, invisibly to the client user agent.</p>

</dd>
<dt id="An-array-reference"><a id="An"></a>An array reference</dt>
<dd>

<p>A <a href="PSGI.html">PSGI</a> array response to return immediately without invoking the wrapped PSGI application.</p>

<p>The array may have fewer than 3 elements, in which case it will be filled to 3&nbsp;elements by pushing the default values: an empty body array, empty headers array, and a 303&nbsp;status&nbsp;code.</p>

<p>If the <code>Location</code> header is missing from a redirect response (i.e. one with 3xx&nbsp;status&nbsp;code), it will be filled in automatically from the value left in <code>PATH_INFO</code> by your callback. (Note that this only allows you to redirect to URLs with the same hostname. To redirect the client to a different host, you will have to supply a <code>Location</code> header manually.)</p>

</dd>
<dt id="A-code-reference"><a id="A1"></a>A code reference</dt>
<dd>

<p>A PSGI application which will be called to process the request. This prevents the wrapped application from being called.</p>

</dd>
<dt id="Any-other-kind-of-reference"><a id="Any"></a>Any other kind of reference</dt>
<dd>

<p>Error. An exception will be thrown.</p>

</dd>
</dl>

<h2 id="response"><code>response</code></h2>

<p>Takes a reference to a function that will be called <i>after</i> the request has been processed and the response is ready to be returned.</p>

<p>On call, <code>$_</code> will be aliased to a specially extended a <a href="https://metacpan.org/pod/Plack::Util#headers"><code>Plack::Util::headers</code></a> object for the response, for convenient alteration of headers. The extension is a <code>status</code> method, which allows you to inspect and modify the response status code.</p>

<p>Just as in <a href="./Plack::Middleware::Rewrite.html#request">&quot;<code>request</code>&quot;</a>, the <a href="PSGI.html">PSGI</a> environment is passed as first and only argument.</p>

<p>Any return value from this function will be ignored unless it is a code reference. In that case it will be used to filter the response body, as documented in <a href="https://metacpan.org/pod/Plack::Middleware#RESPONSE-CALLBACK">&quot;RESPONSE CALLBACK&quot; in Plack::Middleware</a>:</p>

<ul>

<pre><code> return sub {
     my $chunk = shift;
     return unless defined $chunk;
     $chunk =~ s/Foo/Bar/g;
     return $chunk;
 };</code></pre>

<p>The callback takes one argument <code>$chunk</code> and your callback is expected to return the updated chunk. If the given <code>$chunk</code> is undef, it means the stream has reached the end, so your callback should also return undef, or return the final chunk and return undef when called next time.</p>

</ul>

<h1 id="LEGACY-INTERFACE"><a id="LEGACY"></a>LEGACY INTERFACE</h1>

<p>The old interface uses a single attribute, <code>rules</code>, instead of the <code>request</code> and <code>response</code> pair, with a more complex set of return values, containing an ambiguity. It is also less expressive than the new interface.</p>

<p>The old interface is documented here for the purposes of maintaining old code; its use in new code is <a href="https://metacpan.org/pod/perlpolicy#Terminology">discouraged</a>. In the far future it may get removed entirely, and in the meantime it will not gain new features.</p>

<p>The return value of the <code>rules</code> callback is interpreted as follows:</p>

<dl>

<dt id="An-array-reference-(with-at-least-one-element)"><a id="An1"></a><a id="An-array-reference--with-at-least-one-element"></a>An array reference (with at least one element)</dt>
<dd>

<p>A regular <a href="PSGI.html">PSGI</a> response, except that you may omit either or both the headers and body elements. You <i>may not</i> omit the status.</p>

</dd>
<dt id="A-scalar-value-that-looks-like-an-HTTP-status"><a id="A2"></a>A scalar value that looks like an HTTP status</dt>
<dd>

<p>Like returning a reference to a one-element.</p>

<p>Beware: every subroutine in Perl has a return value, even if you do not return anything explicitly. To avoid ambiguities you must return one-element arrays instead of plain values and use an explicit <code>return</code> at the end of your rules:</p>

<pre><code> return [201] if $_ eq &#39;/favicon.ico&#39;;
 s{^/here(?=/|$)}{/there};
 return;</code></pre>

</dd>
<dt id="A-code-reference1"><a id="A3"></a>A code reference</dt>
<dd>

<p>Equivalent to the <a href="./Plack::Middleware::Rewrite.html#response">&quot;<code>response</code>&quot;</a> callback in the new interface, with the same arguments and return values.</p>

</dd>
<dt id="Any-other-kind-of-value"><a id="Any1"></a>Any other kind of value</dt>
<dd>

<p>Internal rewrite.</p>

</dd>
</dl>

<h2 id="Porting-from-the-old-to-the-new-interface"><a id="Porting"></a>Porting from the old to the new interface</h2>

<p>There are two major incompatibilities between the interfaces:</p>

<ol>

<li><p>You can no longer return status codes as plain scalars, as in <code>return 301</code>. You <b>must</b> now <code>return [301]</code> (which you could before, but didn&#39;t have to).</p>

</li>
<li><p>Rewriting the response is no longer done by returning a <code>sub</code>. Instead you must use the <code>response</code> attribute.</p>

<p>This may be inconvient if the function was closing over variables from the <code>rules</code> callback; in that case you now have to explicitly pass that state from one callback to the other through the environment hash. However, such code is rare, and in all other cases your code will be more readable under the new interface.</p>

</li>
</ol>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Aristotle Pagaltzis &lt;pagaltzis@gmx.de&gt;</p>

<h1 id="COPYRIGHT-AND-LICENSE"><a id="COPYRIGHT"></a>COPYRIGHT AND LICENSE</h1>

<p>This software is copyright (c) 2022 by Aristotle Pagaltzis.</p>

<p>This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Plack::Middleware::Rewrite, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Plack::Middleware::Rewrite</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Plack::Middleware::Rewrite</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Plack::Middleware::Rewrite.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
